package cn.iocoder.yudao.module.product.dal.mysql.customermessage;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.product.dal.dataobject.customermessage.CustomerMessageDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.product.controller.admin.customermessage.vo.*;

/**
 * 客服消息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CustomerMessageMapper extends BaseMapperX<CustomerMessageDO> {

    default PageResult<CustomerMessageDO> selectPage(CustomerMessagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerMessageDO>()
                .eqIfPresent(CustomerMessageDO::getUserId, reqVO.getUserId())
                .likeIfPresent(CustomerMessageDO::getUserNickname, reqVO.getUserNickname())
                .eqIfPresent(CustomerMessageDO::getUserAvatar, reqVO.getUserAvatar())
                .eqIfPresent(CustomerMessageDO::getSpuId, reqVO.getSpuId())
                .likeIfPresent(CustomerMessageDO::getSpuName, reqVO.getSpuName())
                .eqIfPresent(CustomerMessageDO::getVisible, reqVO.getVisible())
                .eqIfPresent(CustomerMessageDO::getContent, reqVO.getContent())
                .eqIfPresent(CustomerMessageDO::getContentType, reqVO.getContentType())
                .eqIfPresent(CustomerMessageDO::getSenderType, reqVO.getSenderType())
                .eqIfPresent(CustomerMessageDO::getReplyUserId, reqVO.getReplyUserId())
                .likeIfPresent(CustomerMessageDO::getReplyUserName, reqVO.getReplyUserName())
                .betweenIfPresent(CustomerMessageDO::getSendTime, reqVO.getSendTime())
                .betweenIfPresent(CustomerMessageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CustomerMessageDO::getId));
    }

}